package com.example.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import com.example.dao.FactorOptionRepository;
import com.example.entity.FactorOption;
import com.example.service.PracticeService;

@Service
@CacheConfig(cacheNames="factorOption")
public class PracticeServiceImpl implements PracticeService{
	@Autowired
	private FactorOptionRepository factorOptionDao;
		
	@Override
	@Cacheable
	public List<FactorOption> listFactorOption(PageRequest pageRequest) {
		Page<FactorOption> page = factorOptionDao.findAll(pageRequest);
		long totalElements = page.getTotalElements();
		int number = page.getNumber();
		int numberOfElements = page.getNumberOfElements();
		List<FactorOption> factorOptions = page.getContent();		
		return factorOptions;
	}
	

}
